package latticensprings;

import java.util.ArrayList;
import java.util.Iterator;

import processing.core.PApplet;
import toxi.geom.Vec3D;
import toxi.physics.VerletSpring;

public class CreatureManager {
	
	ArrayList<Creature>creatures;
	PApplet parent;
	
	CreatureManager(PApplet _p)
	{
		parent = _p;
		creatures = new ArrayList<Creature>();
	}
	
	void spawn()
	{
		Vec3D pos = new Vec3D(parent.random(300),parent.random(300),parent.random(300));
		Creature c = new Creature(parent, pos, 60.0f, 147.6f, 137.5f, 70);
		creatures.add(c);
	}
	
	ArrayList<Creature>getCreatures()
	{
		return creatures;
	}
	
	void spawn(Vec3D pob)
	{
		Creature c = new Creature(parent, pob, 60f, 147.6f, 137.5f, 55);
		creatures.add(c);
	}
	
	void renderIso()
	{
		
	}
	
	void renderPhysics()
	{
		
		
		parent.fill(255);
		for(Creature c: creatures)
		{
			for(VerletSpring s : c.bonds)
			{
				parent.stroke(100, 90);
				parent.strokeWeight(1);
				parent.line(s.a.x, s.a.y,s.a.z, s.b.x, s.b.y, s.b.z);				
			}
			for(Vec3D p : c.points)
			{
				parent.strokeWeight(4);
				parent.stroke(255, 150);
				parent.point(p.x, p.y, p.z);
			}
		}
	}
	
	void mateCreatures()
	{
		for(Creature c: creatures)
		{
			if(c.isReady)
			{
				for(Creature cO : creatures)
				{
					if(cO != c)
					{
						if(cO.isReady)
						{
							String childDna;
							
						}
					}
				}
			}
		}
	}
	
	void update()
	{
		for(Creature c:creatures)
		{
			c.update();
		}
		
	}
	
	
}
